package com.monitor.action.admin;

import java.io.PrintWriter;

import com.monitor.action.MonitorActionSupport;
import com.monitor.po.SmsShieldWord;
import com.monitor.service.SmsShieldWordService;
import com.monitor.util.Constants;
import com.monitor.util.Pager;

public class SmsShieldWordAction extends MonitorActionSupport {

	private static final long serialVersionUID = 6516552927092076020L;
	private int cPage;
	private Pager<SmsShieldWord> words;
	private SmsShieldWordService smsShieldWordService;
	private String keywords;
	private String sids;

	@Override
	public String execute() throws Exception {
		cPage = cPage < 1 ? 1 : cPage;
		words = smsShieldWordService.getSmsShieldWords(cPage, Constants.DEFAULT_PAGESIEZE);
		return SUCCESS;
	}

	public void deleteSmsShieldWord() throws Exception {
		PrintWriter out = getWriter();
		boolean success = smsShieldWordService.deleteSmsShieldWord(sids) > 0;
		if (success) {
			out.print("success");
		} else {
			out.print("failed");
		}
		out.flush();
		out.close();
	}

	public void addSmsShieldWord() throws Exception {
		PrintWriter out = getWriter();
		boolean success = smsShieldWordService.addSmsShieldWord(keywords);
		if (success) {
			out.print("success");
		} else {
			out.print("failed");
		}
		out.flush();
		out.close();
	}

	public int getcPage() {
		return cPage;
	}

	public void setcPage(int cPage) {
		this.cPage = cPage;
	}

	public Pager<SmsShieldWord> getWords() {
		return words;
	}

	public void setWords(Pager<SmsShieldWord> words) {
		this.words = words;
	}

	public SmsShieldWordService getSmsShieldWordService() {
		return smsShieldWordService;
	}

	public void setSmsShieldWordService(SmsShieldWordService smsShieldWordService) {
		this.smsShieldWordService = smsShieldWordService;
	}

	public String getKeywords() {
		return keywords;
	}

	public void setKeywords(String keywords) {
		this.keywords = keywords;
	}

	public String getSids() {
		return sids;
	}

	public void setSids(String sids) {
		this.sids = sids;
	}

}
